#ifndef GameObject_h
#define GameObject_h
#include <d3dx9.h>
#include "Texture.h"
#include "ViewPort.h"
#include "Sprite.h"
#include "AnimatedSprite.h"

enum GameObjectType
{
	MarioPlayer = 0,
	BrickNormalType = 1,
	BrickRedType = 2,
	BrickGreenType=3,
	BrickGoldType = 4,
	BrickHardType = 5,
	GroundGrassType = 6,
	GoombaType = 7,
	TurtleType = 8,
	TubeHeadType = 9,
	TubeBodyType = 10,

	//ScenaryObject begins with 'S'
	STree = 100,
	SFlower = 101,
	SCloud = 102
};

enum GameObjectState
{
	normal,
	hurt,//dying
	disappear//remove from scene
};

//subclasses: GameItem and ScenaryObject
class GameObject
{

public:
	GameObject(){}
	//for static objects & Mario
	GameObject(GameObjectType type, D3DXVECTOR2 position)
	{
		_type = type;
		_position = position;
	}
	//for init in quadtree
	GameObject(int id, D3DXVECTOR2 position, int MovingWidth)
	{
		_position = position;
		_movingWidth = MovingWidth;
		_id = id;
	}
	//for init in quadtree, scenary object
	GameObject(int id, D3DXVECTOR2 position, int MovingWidth, GameObjectType scenaryType)
	{
		_position = position;
		_movingWidth = MovingWidth;
		_id = id;
		_type = scenaryType;
	}

	~GameObject(){}

	int GetID()
	{
		return _id;
	}
	bool isCollisionObj()
	{
		return _collisionObj;
	}
	bool isMovableObj()
	{
		return _isMovable;
	}
	D3DXVECTOR2 GetPosition()
	{
		return _position;
	}
	D3DXVECTOR2 GetBottomLeftPosition()
	{
		return D3DXVECTOR2(GetLeft(),GetLowY());
	}

	virtual float GetLowY()
	{
		return _position.y - _h/2;
	}
	virtual float GetLeft()
	{
		return _position.x - _w/2;
	}
	GameObjectType GetType()
	{
		return _type;
	}
	int GetWidth()
	{
		return _w;
	}
	int GetHeight()
	{
		return _h;
	}

	//for UpperLayer
	virtual void LoadResources(LPD3DXSPRITE SpriteHandler, Texture *texture){}
	//for LowerLayer
	virtual void LoadResources(LPD3DXSPRITE SpriteHandler, Texture *texture, GameObjectType type){}

	virtual void RenderFrame(LPDIRECT3DSURFACE9 BackBuffer, ViewPort *viewport){}

protected:
	int _w, _h;
	//frame-center position
	D3DXVECTOR2 _position;

	GameObjectType _type;
	int _movingWidth;
	int _id;
	bool _collisionObj;
	bool _isMovable;
};

#endif